The present invention relates generally to computer software debugging tools, and more particularly, to a system for implementing watchpoint support in a functional simulator.
Debugging tools are commonly used to identify faults or bugs in a computer program that may cause the program to function erroneously. A debugging tool is used to set breakpoints in the computer program for debugging. When the program encounters a breakpoint, the program execution pauses so that various program parameters, viz., register values, memory values, the call stack, and the like, can be verified in order to determine the source of bugs.
A watchpoint is a type of breakpoint that is triggered when a predefined memory address is referenced by the computer program. Triggering the watchpoint generates a watchpoint interrupt, which causes the program execution to be suspended and then continued using a special code called a watchpoint interrupt handler.
Several techniques exist for implementing watchpoints in a debugging tool. One technique is by altering access attributes of memory pages in which watched memory addresses are located, such as to read-only access. When the program accesses that particular memory page to access the memory address, a fault signal indicating a page access violation is generated and a page fault handler is invoked in the debugging tool. The page fault handler determines whether an actual watchpoint has been hit and if so, then a front-end is notified about the watchpoint hit, otherwise access attributes are changed to write-allowed and single-stepping is performed. Upon completion of the single-stepping, the debugging tool resets the access attributes of the memory page to read-only to identify additional subsequent accesses to the memory address.
Though conventional functional simulators successfully enable watchpoint hit detection and debugging using conventional watchpoint mechanisms, they are fraught with several shortcomings. The conventional watchpoint implementation mechanisms are based on memory page access attributes management. As a result, once a watchpoint is encountered, hundreds to thousands of processor cycles are required for invoking the page fault handler and resuming simulation from the faulting instruction, which leads to poor debugging performance. Further, different operating systems have different semantics for altering memory protection attributes. Thus, the debugging tool must be reprogrammed each time it's run on a different operating system platform, which causes portability issues. Further, conventional functional simulators are difficult to integrate with third party tools. The third party tools need to be provided access to internal data structures that model memory to allow change in the access permissions.
Therefore, it would be advantageous to have a functional simulator that has efficient watchpoint support with negligible overhead on simulation performance, is easy to migrate across different host platforms and operating systems, can be seamlessly integrated with third-party tools, and overcomes the above-mentioned limitations of conventional functional simulators.